﻿//-------------------------------------
// WBFSSync - WBFSSync.exe
//
// Copyright 2009 Caian (ÔmΣga Frøst) <frost.omega@hotmail.com> :
//
// WBFSSync is Licensed under the terms of the Microsoft Reciprocal License (Ms-RL)
//
// FormRenameDisc.cs:
//
// Diálogo de edição de nome e código de discos
//
//-------------------------------------

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WBFSSync
{
    public partial class FormRenameDisc : Form
    {
        public String NewName = "";
        public String NewCode = "";

        public FormRenameDisc()
        {
            InitializeComponent();
            textBox_name.MaxLength = WBFSDevice.IsoNameLen;
        }

        public void SetupLanguage()
        {
            this.Text = Language.field_form_name_rename_iso;
            label_namecode.Text = Language.field_namecode;
            button_ok.Text = Language.field_ok;
            button_cancel.Text = Language.field_cancel;
        }

        private void FormRenameDisc_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (DialogResult == DialogResult.OK)
            {
                string code = textBox_code.Text.TrimStart().TrimEnd();
                string name = textBox_name.Text.TrimStart().TrimEnd();

                if ((code.Length != 6) || (name.Length == 0) || (name.Length > WBFSDevice.IsoNameLen))
                {
                    MessageBox.Show(this, String.Format(Language.message_invalid_namecode, Language.field_name, 
                        WBFSDevice.IsoNameLen), Language.AppName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, 
                        MessageBoxDefaultButton.Button1);
                    e.Cancel = true;
                    return;
                }

                //-----

                NewCode = code;
                NewName = name;
            }
        }
    }
}
